package com.yswee.mallnavi.entity.home;

import android.app.Activity;
import android.content.Intent;

import com.google.gson.annotations.SerializedName;
import com.yswee.framework.utils.StringUtils;
import com.yswee.mallnavi.activity.InfoActivity;
import com.yswee.mallnavi.activity.base.WebViewActivity;
import com.yswee.mallnavi.activity.common.PicDialogActivity;
import com.yswee.mallnavi.context.ContextConstant;
import com.yswee.mallnavi.entity.BaseEntity;

public class NavEntity extends BaseEntity {

    private static final long serialVersionUID = 8536080945163059784L;

    public String name;
    @SerializedName("iconUrl")
    public String pic;
    public String description;
    public int displayOrder;
    public int redirectType;
    public String redirectUrl;

    public void gotoIntentPage(Activity activity) {
        /*if (Application.get().getAppConfigure().getIsDebug()) {
            Intent intent = new Intent(activity, InfoActivity.class);
            intent.putExtra(ContextConstant.INTENT_INDEX, "1");
            activity.startActivity(intent);
            return;
        }*/
        if (redirectType == 1) {
            // 应用内跳转
            /*  楼层导购 = 1,
                品牌导购= 3,
                商场介绍 = 5,
                会员中心 = 7,
                优惠活动 = 9,
                畅享美食 = 11
                停车缴费= 12
                */
            int index = -1;
            if ("1".equals(redirectUrl))
                index = 0;
            else if ("3".equals(redirectUrl))
                index = 4;
            else if ("5".equals(redirectUrl))
                index = 3;
            else if ("7".equals(redirectUrl))
                index = 2;
            else if ("9".equals(redirectUrl))
                index = 6;
            else if ("11".equals(redirectUrl))
                index = 5;
            else if ("12".equals(redirectUrl))
                index = 1;
            Intent intent = new Intent(activity, InfoActivity.class);
            intent.putExtra(ContextConstant.INTENT_INDEX, index);
            activity.startActivity(intent);
        } else if (redirectType == 7) {
            // h5链接
            Intent intent = new Intent(activity, WebViewActivity.class);
            intent.putExtra(WebViewActivity.INTENT_URL, redirectUrl);
            activity.startActivity(intent);
        } else if (redirectType == 9) {
            // 弹框
            if (!StringUtils.isEmpty(description)) {
                Intent intent = new Intent(activity, PicDialogActivity.class);
                intent.putExtra(ContextConstant.INTENT_DATA, this);
                activity.startActivity(intent);
            }
        }
    }

}
